﻿using System.Collections;
using System.Collections.Generic;
using GDGeek;
using UnityEngine;

namespace Shows_3D
{
    public class View : Singleton<View>
    {
        [SerializeField] private GameObject login;
        [SerializeField] private GameObject window;
        
        private readonly FSM _fsm = new FSM();
        
        // Start is called before the first frame update
        private void Start()
        {
            _fsm.addState("login",OnLogin());
            _fsm.addState("startStandAlone",OnStartStandAlone());
            _fsm.addState("startHost", OnStartHost());

            _fsm.init("login");
            //_fsm.init("startStandAlone");
        }

        private StateBase OnLogin()
        {
            State state = new State();
            state.onStart += delegate
            {
                login.SetActive(true);
            };
            state.onOver += delegate
            {
                login.SetActive(false);
            };
            state.addAction("startStandAlone","startStandAlone");
            return state;
        }

        private StateBase OnStartStandAlone()
        {
            State state = new State();
            state.onStart += delegate
            {
                window.SetActive(true);
            };
            state.onOver += delegate
            {
                window.SetActive(false);
            };
            return state;
        }
        
        private StateBase OnStartHost()
        {
            State state = new State();
            return state;
        }

        

        public void PostToFsm(string evt)
        {
            Debug.Log(evt);
            _fsm.post(evt);
        }
        // Update is called once per frame
        void Update()
        {

        }
    }
}